package Test1225;

import java.util.ArrayList;

public class Test11 {

        public static void main(String[] args) {
            // 返回2个数组的交集
            int[] arr = {1, 2, 3, 4, 5};
            int[] brr = {3, 4, 5, 6, 7};
            int[] crr = m11(arr, brr);
            for (int c : crr) {
                System.out.println(c);
            }
        }
        public static int[] m11(int[] arr, int[] brr) {
            ArrayList<Integer> result = new ArrayList<>();

            for (int i = 0; i < arr.length; i++) {
                for (int j = 0; j < brr.length; j++) {
                    if (arr[i] == brr[j]) {
                        result.add(arr[i]);
                        break;
                    }
                }
            }

            int[] crr = new int[result.size()];
            for (int i = 0; i < result.size(); i++) {
                crr[i] = result.get(i);
            }

            return crr;
        }


}
